﻿#ifndef DOCKWIDGETCTD_IMCHARTS_H
#define DOCKWIDGETCTD_IMCHARTS_H

#include <QDockWidget>
#include <QChart>
#include <QChartView>
#include <QLineSeries>
#include <QScatterSeries>
#include <QDateTimeAxis>
#include <QValueAxis>
#include <QTableWidget>
#include <QPushButton>
#include <QLabel>

QT_CHARTS_USE_NAMESPACE

class QVBoxLayout;
class QHBoxLayout;
class DockWidgetCTD;
namespace Ui {
class DockWidgetCTD_IMCharts;
}

class DockWidgetCTD_IMCharts : public QDockWidget
{
    Q_OBJECT

public:
    explicit DockWidgetCTD_IMCharts(QWidget *parent = nullptr);
    ~DockWidgetCTD_IMCharts();
    QPushButton* mButtonRotate;

private:
    Ui::DockWidgetCTD_IMCharts *ui;
    QTimer* timerHeartCTD_IMCharts;
    DockWidgetCTD* dockWidgetCTD_IM;

    QChart* mChartCTDIM;
    QLineSeries* m_dseriesTemperature;
    QLineSeries* m_dseriesConductdivity;
    QLineSeries* m_dseriesPressure;
    QScatterSeries* m_scatterSeriesCTDIMTemperature;
    QScatterSeries* m_scatterSeriesCTDIMConductdivity;
    QScatterSeries* m_scatterSeriesCTDIMPressure;
    QDateTimeAxis* m_Time_daxisX;
    QValueAxis* daxisY_Temperature;
    QValueAxis* daxisY_Conductivity;
    QValueAxis* daxisY_Pressure;
    QChartView* dchartView;
    QTableWidget* mBottomTableWidget;
    QLabel* mLabelSampleCount;
    QLabel* mSampleTime;
    QVBoxLayout* mVLayout;
    int mSanpleCount = 0;
    QWidget* mRightBottom;
    QHBoxLayout* mHLayout;
    bool startSampleFlag = true, mFirstSampleCTD_IM = true, mFirstSimple = true;
    double mMaxC=0, mMinC=0, mMaxT=0, mMinT=0, mMaxD=0, mMinD=-0.2;

    QTableWidgetItem* m_New_Value_Conductdivity;
    QTableWidgetItem* m_New_Value_Temperature;
    QTableWidgetItem* m_New_Value_Pressure;

    QString m_currDatetime;
    void setBottomCharts();

signals:
    void sendChangeStatus(bool);

public slots:
    void setOnceSampleCTDIMDataChart(QByteArray& data);
    void recvChangeStatus(bool);
};

#define DockWidgetCTD_IMChartsRelease Singleton<DockWidgetCTD_IMCharts>::Release()
#define DockWidgetCTD_IMChartsInstance Singleton<DockWidgetCTD_IMCharts>::GetInstance()

#endif // DOCKWIDGETCTD_IMCHARTS_H
